package homework.course.role.state;

import homework.course.Message;
import homework.course.MessageType;
import homework.course.role.Student;

public class ConcentrateState extends StudentState {

    public ConcentrateState(Student std) {
        super(std, "专心", "开始聚精会神");
    }

    @Override
    public String speak() {
        String msg = "blablabla";
        std.notifyObservers(new Message(msg, MessageType.WORDS));
        return msg;
    }

    @Override
    public void listen(Object obj, String msg) {
        if(Math.round(Math.random()*4) == 0 || msg == null) {
            std.setState(std.getDistractedState());
        } else if(std != obj){
            std.notifyObservers(new Message("听见了"+obj+"说 "+msg, MessageType.SYSTEM));
        }
    }
}
